#ifndef EQUIPMENT_HPP
#define EQUIPMENT_HPP

#include <iostream>

// 抽象类：灯
class Light
{
public:
    virtual void On() = 0;
    virtual void Off() = 0;

private:
};

// 卧室灯
class LivingRoomLight : public Light
{
public:
    void On() override
    {
        std::cout << "LivingRoomLight is on!" << std::endl;
    }

    void Off() override
    {
        std::cout << "LivingRoomLight is off!" << std::endl;
    }

private:
};

// 抽象类：门
class Door
{
public:
    Door()
    {
    }

    virtual void Open() = 0;
    virtual void Close() = 0;

private:
};

// 外门
class OutDoor : public Door
{
public:
    void Open() override
    {
        std::cout << "OutDoor is open!" << std::endl;
    }

    void Close() override
    {
        std::cout << "OutDoor is closed!" << std::endl;
    }

private:
};

// 抽象类：风扇
class Fan
{
public:
    Fan() {}
    virtual void High() = 0;
    virtual void Medium() = 0;
    virtual void Low() = 0;
    virtual void Off() = 0;

    // 这里会走基类的GetSpeed成员函数
    // unsigned int GetSpeed(){}

    // 所以需要声明成纯虚函数
    virtual unsigned int GetSpeed() = 0;

private:
};

class CeilingFan : public Fan
{
public:
    enum Speed
    {
        HIGH, // 0
        MEDIUM, // 1
        LOW, // 2
        OFF // 3
    };

public:
    CeilingFan()
        : _speed(OFF)
    {
    }
    void High() override
    {
        _speed = HIGH;
        std::cout << "Fan is high!" << std::endl;
    }

    void Medium() override
    {
        _speed = MEDIUM;
        std::cout << "Fan is medium!" << std::endl;
    }

    void Low() override
    {
        _speed = LOW;
        std::cout << "Fan is low!" << std::endl;
    }

    void Off() override
    {
        _speed = OFF;
        std::cout << "Fan is off!" << std::endl;
    }

    unsigned int GetSpeed()
    {
        return _speed;
    }

private:
    unsigned int _speed;
};

// 录音机
class Stereo
{
public:
    // 枚举命令种类
    enum
    {
        ON,
        OFF,
        DVD,
        RADIO,
        VOLUME,
        CD
    };

public:
    Stereo()
        : _prevSet(OFF)
    {
    }

    void On()
    {
        _prevSet = ON;
        std::cout << "Stereo is on!" << std::endl;
    }

    void Off()
    {
        _prevSet = OFF;
        std::cout << "Stereo is off!" << std::endl;
    }

    void SetDvd()
    {
        _prevSet = DVD;
        std::cout << "Dvd is set!" << std::endl;
    }

    void SetRadio()
    {
        _prevSet = RADIO;
        std::cout << "Radio is set!" << std::endl;
    }

    void SetVolume()
    {
        _prevSet = VOLUME;
        std::cout << "Volume is set!" << std::endl;
    }

    void SetCd()
    {
        _prevSet = CD;
        std::cout << "Cd is set!" << std::endl;
    }

    unsigned int GetPrevSet()
    {
        return _prevSet;
    }

private:
    unsigned int _prevSet;
};

#endif
